<?php
$dbms = 'mysql';
$host = 'localhost';
$dbName = 'test';
$dbUser = 'root';
$dbPass = '123456';
$dsn = "$dbms:host=$host;dbName=$dbName";

try {
	$dbh = new PDO($dsn, $dbUser, $dbPass); //初始化一个PDO对象
	if($dbh) {
		echo "连接成功<br/>";
	} else {
		die("数据库连接失败<br/>".$dbh->errorInfo());
	}
	$sql = "select * from users";
	$rs[] = $dbh->query($sql);
	foreach($rs as $row) {
		print_r($row);
		//TODO
	}
	$dbh = null; //释放对象资源，关闭数据库连接
	
	
} catch(Exception $e) {
	die ("Error!: " . $e->getMessage() . "<br/>");
}
?>